﻿using System.Windows;
using System;
using DeepEarth.Core;
using System.Windows.Controls;
using System.ComponentModel;

namespace DeepEarth.Toolkit.Drawing
{
    public abstract class BaseDrawProcessor :  INotifyPropertyChanged
    {
        protected UIElement interactionSurface;
        protected Panel drawingSurface;
        protected Func<Point, Location> viewportPointToLocation;
        protected Func<Location, Point> locationToViewportPoint;

        public event EventHandler<DrawProcessorEventArgs> DrawComplete;

        protected BaseDrawProcessor(UIElement interactionSurface, Panel drawingSurface, Func<Location, Point> locationToViewportPoint, Func<Point, Location> viewportPointToLocation)
        {
            this.interactionSurface = interactionSurface;
            this.drawingSurface = drawingSurface;
            this.locationToViewportPoint = locationToViewportPoint;
            this.viewportPointToLocation = viewportPointToLocation;
        }

        protected void OnDrawComplete(Geometry.Data.Geometry geometry)
        {           
            if (DrawComplete != null)
            {
                DrawComplete(this, new DrawProcessorEventArgs(geometry));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string propertyname)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyname));
            }
        }
    }
}
